//
//  NovaMouthValueFormatter.swift
//  NovaRings
//
//  Created by 李然 on 2023/2/28.
//

import Foundation
import SwiftDate

class NovaMouthValueFormatter: NSObject, NovaXAxisValueFormatter {
    
    let date: Date
    
    init(date: Date) {
        self.date = date
        super.init()
    }
    
    func string(at index: Int) -> String {
        let dayCount = self.date.monthDays
        if index == 0 {
            return "1"
        }
        if (index + 1) % 5 == 0 {
            return "\((index + 1))"
        }
        if dayCount < 30 {
            if index == dayCount - 1 {
                return "\(dayCount)"
            }
        }
        return ""
    }
}
